home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Reference / the cmsp digests ('94-'97) / csmp digest Vol 3 No 039 < prev    next >
Internet Message Format  |  1997-05-06  |  57KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-039
  3. Date: Sun, 26 Jun 1994 23:30:56 +0200 (MET DST)
  4.  
  5. C.S.M.P. Digest             Sun, 26 Jun 94       Volume 3 : Issue 39
  6.  
  7. Today's Topics:
  8.  
  9.         API-headers for Control Strip Modules?
  10.         Apple Event Question
  11.         Are NewPtr() and malloc() different? (source included)
  12.         Closing Down the FINDER
  13.         Fat-stripping
  14.         Finder Comments and Finder Info Updating
  15.         MacTech's ftp site now available!
  16.         QuickDraw GX Display Devices
  17.         SEMI-SUMMARY: Reading JPEGs (with code)
  18.         VBL interrupt & Stack Sniffer
  19.         Writing dcmd with Think C (Q)
  20.  
  21.  
  22.  
  23. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  24. (pottier@clipper.ens.fr).
  25.  
  26. The digest is a collection of article threads from the internet newsgroup
  27. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  28. regularly and want an archive of the discussions.  If you don't know what a
  29. newsgroup is, you probably don't have access to it.  Ask your systems
  30. administrator(s) for details.  If you don't have access to news, you may
  31. still be able to post messages to the group by using a mail server like
  32. anon.penet.fi (mail help@anon.penet.fi for more information).
  33.  
  34. Each issue of the digest contains one or more sets of articles (called
  35. threads), with each set corresponding to a 'discussion' of a particular
  36. subject.  The articles are not edited; all articles included in this digest
  37. are in their original posted form (as received by our news server at
  38. nef.ens.fr).  Article threads are not added to the digest until the last
  39. article added to the thread is at least two weeks old (this is to ensure that
  40. the thread is dead before adding it to the digest).  Article threads that
  41. consist of only one message are generally not included in the digest.
  42.  
  43. The digest is officially distributed by two means, by email and ftp.
  44.  
  45. If you want to receive the digest by mail, send email to listserv@ens.fr
  46. with no subject and one of the following commands as body:
  47.     help                        Sends you a summary of commands
  48.     subscribe csmp-digest Your Name    Adds you to the mailing list
  49.     signoff csmp-digest            Removes you from the list
  50. Once you have subscribed, you will automatically receive each new
  51. issue as it is created.
  52.  
  53. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  54. Questions related to the ftp site should be directed to
  55. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  56. digest are available there.
  57.  
  58. Also, the digests are available to WAIS users.  To search back issues
  59. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  60. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  61.  
  62.  
  63. -------------------------------------------------------
  64.  
  65. >From Gordie Freedman <gordie@kaleida.com>
  66. Subject: API-headers for Control Strip Modules?
  67. Date: 8 Jun 1994 07:17:19 GMT
  68. Organization: Kaleida Labs, Inc.
  69.  
  70. Anybody know where the API is documented to write control strip modules?
  71. I also wasn't sure if there were any header files you used with this
  72. stuff, or if you had to roll your own. Thanks in advance,
  73.  
  74. Gordie Freedman
  75. --
  76.  
  77. gordie@kaleida.com - Kaleida Labs, Inc. - Mountain View, CA
  78.  
  79. +++++++++++++++++++++++++++
  80.  
  81. >From tgaul@halcyon.com (Troy Gaul)
  82. Date: Wed, 08 Jun 1994 21:42:50 -0700
  83. Organization: Infinity Systems
  84.  
  85. In article <2t3r9v$3mr@golden.kaleida.com>, Gordie Freedman
  86. <gordie@kaleida.com> wrote:
  87.  
  88. > Anybody know where the API is documented to write control strip modules?
  89. > I also wasn't sure if there were any header files you used with this
  90. > stuff, or if you had to roll your own. Thanks in advance,
  91.  
  92. They're in the PowerBook 500-series technical notes, which were included on
  93. the June Developer CD.  As far as a header file goes, I didn't see anything
  94. included.
  95.  
  96. _troy
  97. //////// //////___Troy Gaul_________________________tgaul@halcyon.com__ //
  98.   //    //       Infinity Systems ; Redmond, Washington                //
  99.  //    //  //  "Insert witty quote here."                             //
  100. //    //////________________________________________________________ //
  101.  
  102. +++++++++++++++++++++++++++
  103.  
  104. >From jonpugh@netcom.com (Jon Pugh)
  105. Date: Sat, 11 Jun 1994 09:12:12 GMT
  106. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  107.  
  108. Gordie Freedman (gordie@kaleida.com) wrote:
  109. > Anybody know where the API is documented to write control strip modules?
  110. > I also wasn't sure if there were any header files you used with this
  111. > stuff, or if you had to roll your own. Thanks in advance,
  112.  
  113. For that matter, can you get the software any way without buying a 500?
  114.  
  115. Not that I don't want a 500...
  116.  
  117. Jon
  118.  
  119. +++++++++++++++++++++++++++
  120.  
  121. >From tgaul@halcyon.com (Troy Gaul)
  122. Date: Sat, 11 Jun 1994 22:46:33 -0700
  123. Organization: Infinity Systems
  124.  
  125. In article <jonpughCr86wC.LBA@netcom.com>, jonpugh@netcom.com (Jon Pugh)
  126. wrote:
  127.  
  128. > Gordie Freedman (gordie@kaleida.com) wrote:
  129. > > Anybody know where the API is documented to write control strip modules?
  130. > > I also wasn't sure if there were any header files you used with this
  131. > > stuff, or if you had to roll your own. Thanks in advance,
  132. > For that matter, can you get the software any way without buying a 500?
  133. > Not that I don't want a 500...
  134.  
  135. I tried a copy of Control Strip, grabbed off the hard drive of a 500, and
  136. tried it on a desktop Mac, and it wouldn't function, but it worked fine on
  137. a PowerBook 140.  
  138.  
  139. I certainly hope that they allow it to work on desktop Macs as well soon. 
  140. I'd like to use it for a few things myself (like volume and monitor
  141. depth-switching), and its modular architecture makes it easy for third
  142. parties to write modules that would be useful for users of desktop
  143. machines.
  144.  
  145. _troy
  146. //////// //////___Troy Gaul_________________________tgaul@halcyon.com__ //
  147.   //    //       Infinity Systems ; Redmond, Washington                //
  148.  //    //  //  "Insert witty quote here."                             //
  149. //    //////________________________________________________________ //
  150.  
  151. +++++++++++++++++++++++++++
  152.  
  153. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  154. Date: Sun, 12 Jun 1994 14:54:34 +0800
  155. Organization: Department of Computer Science, The University of Western Australia
  156.  
  157. In article <jonpughCr86wC.LBA@netcom.com>, jonpugh@netcom.com (Jon Pugh) wrote:
  158.  
  159. >For that matter, can you get the software any way without buying a 500?
  160.  
  161. Yes.  Get a 280 (:
  162. -- 
  163. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  164. Department of Computer Science, The University of Western Australia
  165.  
  166. +++++++++++++++++++++++++++
  167.  
  168. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  169. Date: Sun, 12 Jun 1994 23:08:17 +0800
  170. Organization: Department of Computer Science, The University of Western Australia
  171.  
  172. In article <tgaul-110694224633@bellevue-ip68.halcyon.com>,
  173. tgaul@halcyon.com (Troy Gaul) wrote:
  174.  
  175. >I tried a copy of Control Strip, grabbed off the hard drive of a 500, and
  176. >tried it on a desktop Mac, and it wouldn't function, but it worked fine on
  177. >a PowerBook 140.  
  178.  
  179. The guys at the WWDC session said they would consider moving it to the
  180. desktop Macs depending on how it was received on the PowerBooks. 
  181. Personally I think it's a TOE (Thing Of Evil (tm)).  That won't stop me
  182. using it of course (:
  183. -- 
  184. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  185. Department of Computer Science, The University of Western Australia
  186.   Now if only the 280C I have on order would arrive ):
  187.  
  188. ---------------------------
  189.  
  190. >From jml16@po.CWRU.Edu (Jonathon M. Lipsky)
  191. Subject: Apple Event Question
  192. Date: 2 Jun 1994 20:01:16 GMT
  193. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  194.  
  195.  
  196. I would like to know if anyone has created their own
  197. AppleEvents to pass data between two programs.  What
  198. I would like to do is impliment an event similar to
  199. an OpenDocument, but I would like to pass a string
  200. that the recieving program that would give it the
  201. needed information.  All of my attempts at implimenting
  202. this have not succeeded, so any examples would be
  203. greatly appreciated.
  204.  
  205. Jon Lipsky (jml16@po.cwru.edu)
  206.  
  207. +++++++++++++++++++++++++++
  208.  
  209. >From Here@There (Someone)
  210. Date: 10 Jun 1994 17:29:50 GMT
  211. Organization: Large Fuzzy Room
  212.  
  213. There's lots of samples around, adapting a 'real' AppleEvent to your
  214. private needs will be easiest.  Here's one way you might want to implement
  215. the send and recieve functions (VERY simple here)
  216.  
  217. // a coupla defines
  218. #define kMyPrivateEventClass 'MYEV'
  219. #define kOpenFileStringEvent 'OPFS'
  220. #define typeMyPString 'MPST'
  221. // Get the address (through PPCBrowser or elsewhere) and the 
  222. // file string and pass them in
  223. OSErr SendFileNameString(ConstStr255 theFullPath,AEDesc * theAddress)
  224. {
  225. AppleEvent theEvent;
  226. OSErr theError = noErr;
  227. // create the event
  228. theError = AECreateAppleEvent(kMyPrivateEventClass,kOpenFileStringEvent,
  229. theAddress,kAutoGenerateReturnID,kAnyTransactionID,&theEvent);
  230. // if no error, add our string
  231. if(theError == noErr)
  232. theError=
  233. AEPutParamPtr(&theEvent,keyDirectObject,typeMyPString,(Ptr)&theFullPath[1],theFullPath[0]);
  234. // send the event
  235. if(theError == noErr)
  236. theError =
  237. AESend(&theEvent,nil,kAENoReply,kAENormalPriority,kAEDefaultTimeout,(IdleProcPtr)
  238. nil,nil);
  239.  
  240. return( theError );
  241. }
  242.  
  243.  
  244. // and on the recieving end, get the thing out
  245.  
  246. pascal OSErr HandleMyOpenFileStr(AppleEvent *messagein, AppleEvent *reply,
  247. long refIn)
  248. {OSErr theError = noErr;
  249. Str255 fileString;
  250. DescType returnedType;
  251. Size returnedSize;
  252. // get the string from the event
  253. theError = AEGetParamPtr(messagein,   // from this event
  254.                            keyDirectObject,    // get the direct object
  255.                            typeMyPString,       // as a pstring
  256.                            &returnedType,     
  257.                            (Ptr)&fileString[1],  // put it here
  258.                            254,      // max size
  259.                            &returnedSize);
  260. if(theError == noErr){
  261. fileString[0] = returnedSize;
  262. theError  = FSOpen(fileString, nil,&fileRefNum);
  263. // fileRefNum is somewhere, whereever you need it
  264. }
  265. return ( theError);
  266. }
  267.  
  268. ---------------------------
  269.  
  270. >From cr@cs.strath.ac.uk (Chris Reid)
  271. Subject: Are NewPtr() and malloc() different? (source included)
  272. Date: Mon, 06 Jun 1994 12:15:52 +0000
  273. Organization: University of Strathclyde
  274.  
  275. Hi everybody,
  276.  
  277. I have written some code that implements Radix Sort (it sorts
  278. an array of longs in linear time). It seems to work well enough,
  279. but one thing is really strange: when I replace the NewPtr()
  280. calls with calls to malloc(), the corresponding free() doesn't seem
  281. to work. Here's roughly what happens:
  282.  
  283.  
  284. // RadixSort implemented using NewPtr() and DisposPtr()
  285.  
  286. mem = FreeMem();    // We've got amount 'mem' bytes in the heap
  287. RadixSort(someArray, numItems);    // Do the sorting
  288. waste = mem - FreeMem();    // Is there a memory leak?
  289.  
  290. waste is always zero (just as it should be), BUT:
  291.  
  292. // RadixSort implemented using malloc() and free()
  293.  
  294. mem = FreeMem();    // We've got amount 'mem' bytes in the heap
  295. RadixSort(someArray, numItems);    // Do the sorting
  296. waste = mem - FreeMem();    // Is there a memory leak?
  297.  
  298. waste is non-zero, a very disturbing fact. But it gets even better,
  299. because on consecutive calls, waste IS zero. It looks as if
  300. malloc() remebers what it's done before. By the way, I need to
  301. use malloc() because the code has to be (sort of) platform independent.
  302.  
  303. The source is attached (hence the cross-posting to alt.sources.mac).
  304. It works, so feel free to use it. Something must be going wrong somewhere,
  305. I can't see it, can anybody else? I'm using THINK C 6.0.1 with Objects.
  306.  
  307. Thanks in advance folks!
  308.  
  309.  
  310. Chris
  311.  
  312. PS: a description of Radix Sort can be found in almost any books on
  313. algorithms
  314.  
  315. /********** Radix Sort Source *************************/
  316.  
  317. #define MAC
  318.  
  319. #ifdef MAC
  320. #define BYTE0 3
  321. #define BYTE1 2
  322. #define BYTE2 1
  323. #define BYTE3 0
  324. #endif
  325.  
  326. // for PC's or any other Big Endian...
  327. #ifdef PC
  328. #define BYTE0 0
  329. #define BYTE1 1
  330. #define BYTE2 2
  331. #define BYTE3 3
  332. #endif
  333.  
  334. #define kNumElements    500        // allocate space for 500 longs at a time
  335. #define kNumPasses        4                    // 32 bit longs - split into 4 * 8 bits
  336. #define kNumBuckets        256  // require 256 buckets
  337. #define kMaxBuffer        100            // sort at most 100 * 500 = 50000 items
  338.  
  339. typedef long    Buffer[kNumElements];    // we don't want to hammer the memory
  340. manager
  341. typedef Buffer    *BufferPtr;                                    // so we allocate space for 500 longs
  342.  
  343. typedef struct
  344.         {
  345.             BufferPtr        theBuffers[kMaxBuffer]; // hold the items as they are added
  346.             long            numItems;                                                                            // how many (filled) buffers have we
  347. got?
  348.             long            current;                                                                                // where does next item go?
  349.         } Bucket, *BucketPtr;
  350.         
  351.  
  352. static BucketPtr theBuckets[kNumBuckets];    // our buckets...
  353.  
  354.  
  355. // allocate space for the buckets and init
  356. void SetupBuckets(void)
  357. {
  358.     long    i, k;
  359.     
  360.     for (i = 0; i < kNumBuckets; i++)
  361.     {
  362.         theBuckets[i] = (BucketPtr) NewPtr(sizeof(Bucket));
  363.         
  364.         for (k = 0; k < kMaxBuffer; k++) theBuckets[i]->theBuffers[k] = NULL;
  365.         theBuckets[i]->numItems = 0;
  366.         theBuckets[i]->current = 0;
  367.     }
  368. }
  369.  
  370. // We're done, release memory
  371. void ClearBuckets(void)
  372. {
  373.     long    i, k;
  374.     
  375.     for (i = 0; i < kNumBuckets; i++)
  376.     {
  377.         for (k = 0; theBuckets[i]->theBuffers[k] != NULL; k++)
  378.         {
  379.             DisposPtr((Ptr) theBuckets[i]->theBuffers[k]);
  380.         }
  381.         DisposPtr((Ptr) theBuckets[i]);
  382.     }
  383. }
  384.  
  385. // Stuff what we've put into the buffers back into the array and release
  386. mem.
  387. void CopyBuckets(long theArray[])
  388. {
  389.     register long    i, j, k, l, count;
  390.     
  391.     count = 0;
  392.     for (i = 0; i < kNumBuckets; i++)
  393.     {
  394.         for (j = 0; j <= theBuckets[i]->numItems; j++) // number of filled
  395. buffers
  396.         {
  397.             if (j < theBuckets[i]->numItems) l = kNumElements; //full buffer
  398.             else l = theBuckets[i]->current;                                                                            //partially full
  399.             
  400.             for (k = 0; k < l; k++)
  401.             {
  402.                 theArray[count] = (*theBuckets[i]->theBuffers[j])[k];
  403.                 count++;
  404.             }
  405.          if (theBuckets[i]->theBuffers[j])
  406.             {
  407.                 free((void *) theBuckets[i]->theBuffers[j]);
  408.                 theBuckets[i]->theBuffers[j] = NULL;
  409.             }
  410.         }
  411.         theBuckets[i]->numItems = 0;
  412.         theBuckets[i]->current = 0;
  413.     }
  414. }
  415.  
  416.  
  417. void RadixSort(long theArray[], long numItems)
  418. {
  419.     register long    i, k;
  420.     register unsigned char    c;
  421.     short Offset[kNumPasses] = {BYTE0,BYTE1,BYTE2,BYTE3};
  422.      unsigned char *p;
  423.  
  424.     long    mem, waste;
  425.     
  426.     mem = FreeMem();
  427.     
  428.     SetupBuckets();
  429.     
  430.     for (i = 0; i < kNumPasses; i++)
  431.     {
  432.         for (k = 0; k < numItems; k++)
  433.         {
  434.             
  435.              p = (unsigned char *) &theArray[k] + Offset[i];
  436.              c = *p;
  437.             if (!theBuckets[c]->theBuffers[theBuckets[c]->numItems])
  438.             {
  439.                 theBuckets[c]->theBuffers[theBuckets[c]->numItems] = (BufferPtr)
  440. malloc(sizeof(Buffer));
  441.                 theBuckets[c]->current = 0;
  442.             }
  443.             
  444.             (*theBuckets[c]->theBuffers[theBuckets[c]->numItems])[theBuckets[c]->current]
  445. = theArray[k];
  446.             
  447.             theBuckets[c]->current++;
  448.             if (theBuckets[c]->current >= kNumElements)
  449.             {
  450.                 theBuckets[c]->numItems++;
  451.                 theBuckets[c]->current = 0;
  452.             }
  453.         }
  454.         CopyBuckets(theArray);
  455.     }
  456.     ClearBuckets();
  457.     waste = mem - FreeMem();
  458. }
  459.  
  460.  
  461.  
  462. +-----------------------------------------------------------------+
  463. |Chris Reid                            e-mail: cr@cs.strath.ac.uk |
  464. |Dept. Computer Science, Strathclyde University, Glasgow, Scotland|
  465. +-----------------------------------------------------------------+
  466.  
  467. +++++++++++++++++++++++++++
  468.  
  469. >From pcastine@jake.prz.tu-berlin.de (Peter Castine)
  470. Date: Mon, 6 Jun 1994 14:42:31 GMT
  471. Organization: PRZ TU-Berlin
  472.  
  473. cr@cs.strath.ac.uk (Chris Reid) writes:
  474. >
  475. >Hi everybody,
  476. >
  477. >I have written some code that implements Radix Sort (it sorts
  478. >an array of longs in linear time). It seems to work well enough,
  479. >but one thing is really strange: when I replace the NewPtr()
  480. >calls with calls to malloc(), the corresponding free() doesn't seem
  481. >to work. Here's roughly what happens:
  482. >
  483. [stuff deleted]
  484.  
  485. Well, as I remember, malloc() calls _NewPtr, but free() (at least
  486. in the THINK C implementation) does not (necessarily) call _DisposPtr.
  487. The malloc/free implementation does some of its own store management.
  488. So, what you're seeing is not (ahem, necessarily) a memory leak.
  489. Check the sources of malloc() and free() for details.
  490.  
  491. BTW, I've seen some code that checks the endian-ness of the machine
  492. at runtime. This might be a better idea than depending upon MAC
  493. or PC being #defined. The trick is to store an arbitrary value
  494. (like 0x1234) into a short, and looking at the first byte (by 
  495. typecasting the address of the variable to a char*). 
  496. Just a suggestion.
  497.  
  498. Cheers,
  499. -- 
  500. Peter Castine              | Dr. Who quote du jour:
  501. pcastine@prz.tu-berlin.de  |     Have you noticed the way people's
  502. ===========================| intelligence capabilities decline sharply
  503.  ``Have Mac, will travel'' | the minute they start waving guns around?
  504.  
  505. +++++++++++++++++++++++++++
  506.  
  507. >From isis@netcom.com (Mike Cohen)
  508. Date: Mon, 6 Jun 1994 17:05:40 GMT
  509. Organization: ISIS International
  510.  
  511. cr@cs.strath.ac.uk (Chris Reid) writes:
  512.  
  513. <snip>
  514.  
  515. >// RadixSort implemented using malloc() and free()
  516.  
  517. >mem = FreeMem();    // We've got amount 'mem' bytes in the heap
  518. >RadixSort(someArray, numItems);    // Do the sorting
  519. >waste = mem - FreeMem();    // Is there a memory leak?
  520.  
  521. >waste is non-zero, a very disturbing fact. But it gets even better,
  522. >because on consecutive calls, waste IS zero. It looks as if
  523. >malloc() remebers what it's done before. By the way, I need to
  524. >use malloc() because the code has to be (sort of) platform independent.
  525.  
  526. In most implementations of malloc/free, rather than simply calling NewPtr &
  527. DisposePtr directly, they will allocate a larger pool calling NewPtr as
  528. necessary and then manage the space in that pool. In most cases, this pool
  529. storage won't be returned to the mac memory manager, but will remain available
  530. for future malloc() calls. Therefore, FreeMem() will report that storage was
  531. lost.
  532. -- 
  533. Mike Cohen - isis@netcom.com
  534. NewtonMail, eWorld: MikeC / ALink: D6734 / AOL: MikeC20
  535. Home Page: file://ftp.netcom.com/pub/isis/home.html
  536.  
  537. +++++++++++++++++++++++++++
  538.  
  539. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  540. Date: Mon, 6 Jun 1994 21:11:22 GMT
  541. Organization: Apple Computer
  542.  
  543. Chris Reid, cr@cs.strath.ac.uk writes:
  544. > waste is non-zero, a very disturbing fact. But it gets even better,
  545. > because on consecutive calls, waste IS zero. It looks as if
  546. > malloc() remebers what it's done before. By the way, I need to
  547. > use malloc() because the code has to be (sort of) platform independent.
  548.  
  549. This is a very Frequently Asked Question. malloc and free as implemented by
  550. the ANSI library (on all know Mac development systems) grab large blocks of
  551. memory via NewPtr, then suballocate those blocks for successive mallocs.
  552. These large blocks don't get returned -- it would be difficult to figure out
  553. when to return them. But the memory in them does get re-used by malloc if you
  554. free it.
  555.  
  556. Think of it as if malloc and free create a new heap from which to allocate
  557. memory.
  558.  
  559. --Jens Alfke
  560.   jens_alfke@powertalk              Rebel girl, rebel girl,
  561.             .apple.com              Rebel girl you are the queen of my world
  562.  
  563. +++++++++++++++++++++++++++
  564.  
  565. >From hall_j@sat.mot.com (Joseph Hall)
  566. Date: Mon, 6 Jun 1994 18:48:45 GMT
  567. Organization: Motorola Inc., Satellite Communications
  568.  
  569. Seems it was cr@cs.strath.ac.uk (Chris Reid) who said:
  570. >Hi everybody,
  571. >
  572. >I have written some code that implements Radix Sort (it sorts
  573. >an array of longs in linear time). It seems to work well enough,
  574. >but one thing is really strange: when I replace the NewPtr()
  575. >calls with calls to malloc(), the corresponding free() doesn't seem
  576. >to work. Here's roughly what happens:
  577.  
  578. It used to be that THINK C's free() just didn't free blocks.  It
  579. was meant to work that way.  I don't recall whether it didn't free
  580. any blocks or whether it only freed blocks larger than a certain size.
  581.  
  582. MPW's malloc(), on the other hand, was busted around 3.0 or 3.1.
  583. Do some malloc-ing and some free-ing and eventually it would crash.
  584. I don't know whether that was ever fixed, though I reported it.
  585.  
  586. I suggest that you use NewPtr() on the Mac to obtain memory, then
  587. manage it with a memory allocator of your own.  The Aho/Hopcroft/
  588. Ullman algorithms book has a section on allocators, or you could
  589. just make allocations of the desired size with NewPtr().  You can always
  590. obtain a separate zone to work with, too, which makes it easy to
  591. free a whole bunch of stuff en masse.
  592.  
  593. -- 
  594. Joseph Nathan Hall | Joseph's Law of Interface Design: Never give your users
  595. Software Architect | a choice between the easy way and the right way.
  596. Gorca Systems Inc. |                 joseph@joebloe.maple-shade.nj.us (home)
  597. (on assignment)    | (602) 732-2549 (work)  Joseph_Hall-SC052C@email.mot.com
  598.  
  599. +++++++++++++++++++++++++++
  600.  
  601. >From Mark Hanrek <hanrek@cts.com>
  602. Date: Wed, 8 Jun 1994 00:53:17 GMT
  603. Organization: The Information Workshop
  604.  
  605. It seems to me that one should be able to copy the source code for
  606. malloc() and free() into their project, and then determine how to modify
  607. it to actually free the memory that was originally malloc'd.
  608.  
  609. This is what I figure I am going to have to do, because I just discovered
  610. that when I made this routine into a code resource (XCMD) which will run
  611. within HyperCard, it used malloc, and I absolutely must return that
  612. memory, and there is no way I could possibly convert the source code to
  613. using NewPtr without opening a Pandora's Box.  It's just too complex.
  614.  
  615. <sigh>
  616.  
  617. Mark Hanrek
  618.  
  619. +++++++++++++++++++++++++++
  620.  
  621. >From ray@sfu.ca (Ray Davison) (Ray Davison)
  622. Date: Fri, 10 Jun 1994 22:34:46 GMT
  623. Organization: Simon Fraser University
  624.  
  625. In article <Cr1zsu.K4G@crash.cts.com>, Mark Hanrek <hanrek@cts.com> wrote:
  626.  
  627. > It seems to me that one should be able to copy the source code for
  628. > malloc() and free() into their project, and then determine how to modify
  629. > it to actually free the memory that was originally malloc'd.
  630. > This is what I figure I am going to have to do, because I just discovered
  631. > that when I made this routine into a code resource (XCMD) which will run
  632. > within HyperCard, it used malloc, and I absolutely must return that
  633. > memory, and there is no way I could possibly convert the source code to
  634. > using NewPtr without opening a Pandora's Box.  It's just too complex.
  635.  
  636. I once needed to use some Unix code and also didn't want it to use malloc
  637. and free. All I did was include the following in the source:
  638.  
  639. #define free(p) DisposPtr((Ptr)(p))
  640. #define calloc(s,n) ((void *)NewPtrClear(s*n))
  641. #define malloc(s) ((void *)NewPtr(s))
  642.  
  643. Worked fine for me.
  644.  
  645. -- 
  646. Ray Davison
  647. ray@sfu.ca
  648.  
  649. +++++++++++++++++++++++++++
  650.  
  651. >From pcastine@tubprz.prz.tu-berlin.de (Peter Castine)
  652. Date: Sun, 12 Jun 1994 15:28:36 GMT
  653. Organization: PRZ TU-Berlin
  654.  
  655. ray@sfu.ca (Ray Davison) (Ray Davison) writes:
  656. >
  657. >I once needed to use some Unix code and also didn't want it to use malloc
  658. >and free. All I did was include the following in the source:
  659. >
  660. >#define free(p) DisposPtr((Ptr)(p))
  661. >#define calloc(s,n) ((void *)NewPtrClear(s*n))
  662.                                          ~~~~~
  663. >#define malloc(s) ((void *)NewPtr(s))
  664. >
  665. >Worked fine for me.
  666.  
  667. Just on principle, it might be a better idea to put parentheses
  668. around s and n in the macro {to wit: NewPtrClear((s)*(n)) }.
  669. It is, admittedly, a little rare to have complicated expressions 
  670. as parameters to calloc, but 't can happen.
  671.  
  672. Picky me ;-}
  673.  
  674. -- 
  675. Peter Castine              | Dr. Who quote du jour:
  676. pcastine@prz.tu-berlin.de  |     Have you noticed the way people's
  677. ===========================| intelligence capabilities decline sharply
  678.  ``Have Mac, will travel'' | the minute they start waving guns around?
  679.  
  680. ---------------------------
  681.  
  682. >From Jake_V._Bouvrie@bcsmac.org (Jake V. Bouvrie)
  683. Subject: Closing Down the FINDER
  684. Date: Sun,  5 Jun 94 11:52:50 EST
  685. Organization: (none)
  686.  
  687. Is it possible to quit the finder from your app, so that there isn't a finder to
  688. go to ?
  689.  
  690. +++++++++++++++++++++++++++
  691.  
  692. >From mclow@coyote.csusm.edu (Marshall Clow)
  693. Date: 5 Jun 1994 10:33:24 -0700
  694. Organization: California State University San Marcos
  695.  
  696. Jake V. Bouvrie (Jake_V._Bouvrie@bcsmac.org) wrote:
  697. >Is it possible to quit the finder from your app, 
  698. >so that there isn't a finder to go to ?
  699.  
  700. Sure, send it a 'quit' apple event.
  701. Under system 6 it's harder.
  702.  
  703. Marshall Clow
  704. Aladdin Systems
  705. mclow@san_marcos.csusm.edu
  706.  
  707.  
  708. +++++++++++++++++++++++++++
  709.  
  710. >From kenlong@netcom.com (Ken Long)
  711. Date: Sun, 5 Jun 1994 18:19:43 GMT
  712. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  713.  
  714. Do you mean in code or in practice?
  715.  
  716. -Ken-
  717.  
  718. +++++++++++++++++++++++++++
  719.  
  720. >From grobbins@apple.com (Grobbins)
  721. Date: 5 Jun 1994 17:03:01 -0700
  722. Organization: Skunkworks
  723.  
  724. In article <2st294$phj@coyote.csusm.edu>,
  725. Marshall Clow <mclow@coyote.csusm.edu> wrote:
  726. >Jake V. Bouvrie (Jake_V._Bouvrie@bcsmac.org) wrote:
  727. >>Is it possible to quit the finder from your app, 
  728. >>so that there isn't a finder to go to ?
  729. >Sure, send it a 'quit' apple event.
  730.  
  731. Not so fast; there are issues to consider.  Pasted
  732. below is the discussion from the Finder Q&A tech note
  733. (TB 535).
  734.  
  735. Grobbins             grobbins@apple.com
  736.  
  737. Usual disclaimers apply.
  738.  
  739. ______
  740.  
  741.  
  742. from Macintosh Technical Note TB 535 - Finder Q&As:
  743.  
  744. Quitting System 7 Finder
  745. Date Written:  4/17/92
  746. Last reviewed:  6/14/93
  747. I've been thinking of shutting down the System 7 Finder. Is this a cool
  748. thing to do in my application?
  749. ___
  750. We normally recommend that you don't quit the System 7 Finder application.
  751. Nevertheless, there may be a few good reasons to shut down the Finder. For
  752. example, the Installer (the only application Apple ships with a good reason
  753. to do so) sometimes needs to shut down the Finder and all other applications
  754. to make sure system resources aren't being used while they're being updated
  755. by the Installer.
  756.  
  757. If you find yourself in a situation where you need to shut down the Finder,
  758. you should know about a few things:
  759. * Before you shut down the System 7 Finder, use the Process Manager to see
  760. if the File Sharing Extension is running. If so, you should shut it down
  761. before shutting down the Finder. The File Sharing Extension shouldn't be
  762. running without the Finder because the Finder is the only user interface the
  763. File Sharing Extension has. You shouldn't take away the user interface to
  764. file sharing.
  765.  
  766.  There's another good reason to shut down the File Sharing Extension before
  767. the Finder. The Network Extension (not the Network control panel) handles
  768. all the user interface transactions among the Finder, the File Sharing
  769. Monitor control panel, the Sharing Setup control panel, the Users & Groups
  770. control panel, and the File Sharing Extension (the file server). The Network
  771. Extension opens another file, the Users & Groups Data File, so that it can
  772. manipulate users and groups. When you shut down the Finder (with a
  773. kAEQuitApplication Apple event), the Network Extension and its connection to
  774. the Users & Groups Data File are also closed (almost). Because of a minor
  775. bug in the system, the File Manager thinks that the file is closed and that
  776. the FCB used by that access path is free for reuse; however, the File
  777. Sharing Extension thinks the access path to the Users & Groups Data File
  778. from the Network Extension is still open. When the File Manager attempts to
  779. reuse that FCB to open another file later, the file is opened, but because
  780. the File Sharing Extension thinks that FCB is still in use by the Network
  781. Extension, it won't allow access to the file and it returns opWrErr (-49) to
  782. the Open call. At this point, the file that someone was attempting to open
  783. can't be accessed or closed.
  784.  
  785. * If the Finder is shut down and then eventually relaunched, there may be
  786. some fragmentation of the MultiFinder heap. This can occur because the
  787. Finder is the first application to be started, so it's always first in the
  788. MultiFinder heap. When you shut it down, that memory becomes available and
  789. other processes might occupy that space. When the Finder is restarted, if it
  790. can't get into its original space in the MultiFinder heap, it will get
  791. loaded somewhere else and probably won't be shut down again.
  792.  
  793. * In System 7, the Finder is responsible for filling the Apple menu with the
  794. items in the Apple Menu Items folder. When the Finder is gone, so are the
  795. Apple menu items, including things that are important to most users (like
  796. control panels).
  797.  
  798. * If the user has selected background printing with a LaserWriter or
  799. StyleWriter, nothing will print while the Finder is gone. That's because the
  800. Finder is responsible for monitoring the PrintMonitor Documents folder and
  801. launching the PrintMonitor application when necessary.
  802.  
  803.  
  804. +++++++++++++++++++++++++++
  805.  
  806. >From Jake_V._Bouvrie@bcsmac.org (Jake V. Bouvrie)
  807. Date: Sun,  5 Jun 94 21:31:29 EST
  808. Organization: (none)
  809.  
  810. >Do you mean in code or in practice?
  811. Well, i mean in Code, like i call it in my program....
  812.  
  813. +++++++++++++++++++++++++++
  814.  
  815. >From David_B._Lamkins@bmugbost.uu.holonet.net
  816. Date: Wed, 08 Jun 1994 14:29:18 EST
  817. Organization: BMUG Boston
  818.  
  819. Jake_V._Bouvrie@bcsmac.org (Jake V. Bouvrie) wrote:
  820.  
  821. >Is it possible to quit the finder from your app, so that there
  822. >isn't a finder to go to ?
  823.  
  824. Yes.  Assuming you don't mind that it's not a nice thing to do,
  825. you can use Process Manager calls (see IM VI or whatever new
  826. world volume has it) to kill the Finder.  You should also
  827. kill the background process that the File Sharing extension
  828. runs when sharing is turned on - to do otherwise risks
  829. corrupting the Users & Groups file.  This won't get rid of the
  830. Finder forever - it will restart as soon as all other
  831. applications quit.
  832.  
  833. Dave
  834. -BMUG Boston 617-721-5840, East Coast BBS of The World's Largest Mac User Group 
  835.  
  836. +++++++++++++++++++++++++++
  837.  
  838. >From wombat@claris.com (Scott Lindsey)
  839. Date: Wed, 08 Jun 1994 20:14:43 -0800
  840. Organization: Claris Corporation, Vancouver WA
  841.  
  842. In article <2stp3l$kf@apple.com>, grobbins@apple.com (Grobbins) wrote:
  843.  
  844. > In article <2st294$phj@coyote.csusm.edu>,
  845. > Marshall Clow <mclow@coyote.csusm.edu> wrote:
  846. > >Jake V. Bouvrie (Jake_V._Bouvrie@bcsmac.org) wrote:
  847. > >>Is it possible to quit the finder from your app, 
  848. > >>so that there isn't a finder to go to ?
  849. > >Sure, send it a 'quit' apple event.
  850. > Not so fast; there are issues to consider.  Pasted
  851. > below is the discussion from the Finder Q&A tech note
  852. > (TB 535).
  853.  
  854. Not to mention that PowerTalk has certain Finder dependencies.  There's
  855. lots of things that don't work if the Finder isn't running (or even if it
  856. gets relaunched!)  We ran into problems just using Apple's Installer. 
  857. After the Finder restarts, PowerTalk gets in a funny state where it's
  858. basically useless.
  859.  
  860. -- 
  861. Scott Lindsey <wombat@claris.com, wombat@apple.com>
  862. Std. disclaimer: my opinions, not Claris', not Apple's.
  863.  
  864. ---------------------------
  865.  
  866. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  867. Subject: Fat-stripping
  868. Date: Thu,  2 Jun 1994 14:52:31 -0400
  869. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  870.  
  871. Which is to say, cutting a fat binary down to a 68K executable, thus
  872. saving space. And the parallel operation of cutting a fat binary down to
  873. a PowerMac executable. 
  874.  
  875. Someone must have written a tiny app to do this. Someone? Anyone? I just
  876. downloaded JPEGview 3.3, which is wonderful, but it looks like I can
  877. save half the disk space it takes up. This situation will continue to
  878. aggravate as fat binaries catch on.
  879.  
  880. (Reassurance: obviously, if I give anyone a copy of a shareware program
  881. which I have fat-stripped, I am obligated to tell them that fact and
  882. point them at an unadulterated version if they want it. Also, some
  883. shareware packages prohibit distributing altered copies at all, and this
  884. would certainly count as alteration. I think a well-behaved fat-stripper
  885. would append "68K" or "PMac" to the executable file name.)
  886.  
  887. If nobody has written this thing, I guess I will. The fat->68K stripper,
  888. anyhow. Unless it's non-trivial (which I guess is the only reason for it
  889. not being written.) Can one just reduce the data fork of the APPL to
  890. zero length, or is it trickier?
  891.  
  892. --Z
  893.  
  894. +++++++++++++++++++++++++++
  895.  
  896. >From tgaul@halcyon.com (Troy Gaul)
  897. Date: Fri, 03 Jun 1994 00:04:49 -0800
  898. Organization: Infinity Systems
  899.  
  900. In article <shvWdjy00gpIIUVOsF@andrew.cmu.edu>, "Andrew C. Plotkin"
  901. <ap1i+@andrew.cmu.edu> wrote:
  902.  
  903. > Which is to say, cutting a fat binary down to a 68K executable, thus
  904. > saving space. And the parallel operation of cutting a fat binary down to
  905. > a PowerMac executable. 
  906. > Someone must have written a tiny app to do this. Someone? Anyone? I just
  907. > downloaded JPEGview 3.3, which is wonderful, but it looks like I can
  908. > save half the disk space it takes up. This situation will continue to
  909. > aggravate as fat binaries catch on.
  910. >  
  911. > (Reassurance: obviously, if I give anyone a copy of a shareware program
  912. > which I have fat-stripped, I am obligated to tell them that fact and
  913. > point them at an unadulterated version if they want it. Also, some
  914. > shareware packages prohibit distributing altered copies at all, and this
  915. > would certainly count as alteration. I think a well-behaved fat-stripper
  916. > would append "68K" or "PMac" to the executable file name.)
  917. > If nobody has written this thing, I guess I will. The fat->68K stripper,
  918. > anyhow. Unless it's non-trivial (which I guess is the only reason for it
  919. > not being written.) Can one just reduce the data fork of the APPL to
  920. > zero length, or is it trickier?
  921.  
  922. I've written such a thing, mostly, anyway.  This type of program is much
  923. more complicated than it may first appear.  
  924.  
  925. The main reason I haven't released/finished mine is that I'm somewhat
  926. worried about the liability if the stripping process damages someone's
  927. application.  And it might be that the stripping will work fine, but if
  928. they try to run it later on the other type of machine, it might do
  929. something bad (rather than just fail to work).  This could be a problem
  930. that would take months, even years to develop, so the original copy might
  931. have been around for easy restoration.
  932.  
  933. Also, stripping 68K code is practically impossible to do safely for various
  934. reasons.
  935.  
  936. _troy gaul
  937.  infinity systems
  938.  
  939. +++++++++++++++++++++++++++
  940.  
  941. >From tgaul@halcyon.com (Troy Gaul)
  942. Date: Sat, 04 Jun 1994 22:14:44 -0700
  943. Organization: Infinity Systems
  944.  
  945. In article <scouten-030694090448@cactus.stu.umn.edu>,
  946. scouten@maroon.tc.umn.edu (Eric Scouten) wrote:
  947.  
  948. > You don't really have that much to worry about. If you're writing to strip
  949. > PowerPC code, you only have to read the 'cfrg' resource, find out where the
  950. > PowerPC code is, and get rid of it. In almost all cases, it will be in the
  951. > data fork -- though it is possible to put it in resources (or a *part* of
  952. > the data fork). Such cases are *very* rare, and unsupported by at least two
  953. > of the three major PowerPC development systems.
  954. > If you strip the PPC code properly, you can still launch the application on
  955. > a PPC machine; it'll just run in emulation mode instead. (Just be sure you
  956. > also remove the 'cfrg' resource!)
  957.  
  958. My program actually parses the 'cfrg' resource, and it is aware of the
  959. types of the blocks, etc. (for instance, when the Code Fragment Manager is
  960. implemented on 68K, it won't remove those).
  961.  
  962. The problem with stripping 68K code is that a PowerPC application might
  963. need some of the code resources if it has only been partially ported, and
  964. this is not described in the 'cfrg' resource or anywhere else.
  965.  
  966. _troy
  967. //////// //////___Troy Gaul_________________________tgaul@halcyon.com__ //
  968.   //    //       Infinity Systems ; Redmond, Washington                //
  969.  //    //  //  "Insert witty quote here."                             //
  970. //    //////________________________________________________________ //
  971.  
  972. +++++++++++++++++++++++++++
  973.  
  974. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  975. Date: Mon,  6 Jun 1994 10:41:25 -0400
  976. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  977.  
  978. Thanks to everyone who replied. The generic answer seems to be "get
  979. IM-PPC System Software and look up the 'cfrg' resource," which I will do
  980. as soon as my other fifty-seven projects allow me some spare time.
  981.  
  982. --Z
  983.  
  984. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  985.  
  986. +++++++++++++++++++++++++++
  987.  
  988. >From Ron_Hunsinger@bmug.org (Ron Hunsinger)
  989. Date: Sun, 12 Jun 94 08:55:52 PST
  990. Organization: Berkeley Macintosh Users Group
  991.  
  992. scouten@maroon.tc.umn.edu (Eric Scouten) writes:
  993.  
  994. >If you strip the 68K code properly, you can of course launch on a PPC
  995. >machine. If you attempt to launch such an app on a 68K machine, the Finder
  996. >will give you an error box saying something like "The application could not
  997. >be launched because an error of type -192 occurred." (-192 is resource not
  998. >found, probably the 'CODE 1' resource) This is harmless; it just means you
  999. >won't be able to use the app. (Unless they ever come out with PowerPC
  1000. >emulation on 68K... snicker snicker!)
  1001.  
  1002. Or, you could substitute for the 68k code a tiny 68k program that puts up
  1003. an alert saying "This program will not run on your machine because it has
  1004. been customized for PowerMac execution only."  Then you don't have to 
  1005. explain what "an error of type -192" means.
  1006.  
  1007. -Ron Hunsinger
  1008.  
  1009. ---------------------------
  1010.  
  1011. >From eshieh@volga.EECS.Berkeley.EDU (Eric Shieh)
  1012. Subject: Finder Comments and Finder Info Updating
  1013. Date: 9 Jun 1994 21:48:21 GMT
  1014. Organization: University of California, Berkeley
  1015.  
  1016.  
  1017. Hello all, there are a few minor quirks I'm trying to fix in my program.
  1018. First, how do you get the comments off of a floppy disk???IM VI says
  1019. it doesn't use the Desktop Manager for volumes < 2 megs, so you cant
  1020. use PBDTGetComment...I tried using the Morefiles routine, but it doesn't
  1021. seem to like floppies either...
  1022.  
  1023. Second problem: Is there any way to have the Finder update a file's label?
  1024. On a Powermac, whenever I set the label, then do a GetFInfo, the old label
  1025. is still returned, only when I close and re-open the folder does the label
  1026. get correctly set.  I tried "touching" the folder (usually used for
  1027. updating a file's icons) to no avail. This is annoying cuz my program
  1028. can read the label, but if the user changes it, then immediately give it to
  1029. my program, it'll read the old label still...
  1030.  
  1031. Thanks,
  1032. Eric
  1033. eshieh@cory.berkeley.edu
  1034.  
  1035.  
  1036. +++++++++++++++++++++++++++
  1037.  
  1038. >From leonardr@netcom.com (Leonard Rosenthol)
  1039. Date: Sun, 12 Jun 1994 23:13:14 GMT
  1040. Organization: Aladdin Systems, Inc.
  1041.  
  1042. In article <2t82n5$9g0@agate.berkeley.edu>, eshieh@volga.EECS.Berkeley.EDU
  1043. (Eric Shieh) wrote:
  1044.  
  1045. > Hello all, there are a few minor quirks I'm trying to fix in my program.
  1046. > First, how do you get the comments off of a floppy disk???IM VI says
  1047. > it doesn't use the Desktop Manager for volumes < 2 megs, so you cant
  1048. > use PBDTGetComment...I tried using the Morefiles routine, but it doesn't
  1049. > seem to like floppies either...
  1050.    Correct.  Floppies (volumes < 2 meg) use the old Sys6 style DTDB for
  1051. which there were no API calls for accessing the information.  Your only
  1052. option, if you MUST support it, is to figure out the format of the old
  1053. DTDB files and then read/write them...
  1054.  
  1055.  
  1056. > Second problem: Is there any way to have the Finder update a file's label?
  1057. >
  1058.    Not w/o a bunch of weird trap patches, nope.   
  1059.  
  1060.    The problem is that the Finder keeps certain things in an internal
  1061. "cache" and doesn't go back to disk (or doesn't flush it to disk) that
  1062. often.  There is also no (easy/approved/documented) way to get the Finder
  1063. to flush the cache, or reload the data.   There is an Apple event in the
  1064. new Scriptable Finder that allows you to force an "update" on a file, but
  1065. that doesn't help in all cases.
  1066.  
  1067.  
  1068. Leonard
  1069. - ------------------------------------------------------------------------
  1070. Leonard Rosenthol                      Internet:       leonardr@netcom.com
  1071. Director of Advanced Technology        AppleLink:      MACgician
  1072. Aladdin Systems, Inc.                  GEnie:          MACgician
  1073.  
  1074. ---------------------------
  1075.  
  1076. >From Neil Ticktin <publisher@xplain.com>
  1077. Subject: MacTech's ftp site now available!
  1078. Date: Thu, 9 Jun 1994 05:09:17 GMT
  1079. Organization: MacTech Magazine/Xplain Corp.
  1080.  
  1081. To all,
  1082.  
  1083. By popular demand (mostly from you folks on comp.sys.mac.programmer),
  1084. we've now established our ftp site.  To get to our files, do an anonymous
  1085. ftp to ftp.netcom.com and change directories to /pub/xplain -- there
  1086. you'll see our latest files.
  1087.  
  1088. In this site, we will regularly post the most recent 3 months of source
  1089. code to accompany the articles in the magazine.  That way, you can
  1090. download the info and play with the code as soon as you get the magazine.
  1091.  This brings our Internet support inline with our support on America
  1092. Online, CompuServe and AppleLink.
  1093.  
  1094. Please let us know if you have any suggestions.
  1095.  
  1096. Hope it helps,
  1097.  
  1098. Neil Ticktin
  1099. MacTech Magazine
  1100. - ---------------------------------------------------------------------
  1101.            Neil Ticktin, MacTech Magazine (formerly MacTutor)
  1102. PO Box 250055, Los Angeles, CA 90025 * 310-575-4343 * Fax: 310-575-0925
  1103.  For more info, anonymous ftp to ftp.netcom.com and cd to /pub/xplain
  1104.   custservice@xplain.com * editorial@xplain.com * adsales@xplain.com
  1105. marketing@xplain.com * accounting@xplain.com * pressreleases@xplain.com
  1106.    progchallenge@xplain.com * publisher@xplain.com * info@xplain.com
  1107.  
  1108. ---------------------------
  1109.  
  1110. >From Willie Abrams <willie-abrams@uokhsc.edu>
  1111. Subject: QuickDraw GX Display Devices
  1112. Date: 6 Jun 1994 19:03:50 GMT
  1113. Organization: OU Health Sciences Center
  1114.  
  1115. In working with GX, I was wondering -
  1116.  
  1117. When the graphics system gets loaded, I assume GX walks the 
  1118. list of GDevices known to QuickDraw, and creates viewDevices
  1119. for them...
  1120.  
  1121. Would it be possible to have GX draw to a display that was not
  1122. known to QuickDraw? That is, can GX recognize "GX" only display
  1123. hardware?
  1124.  
  1125. And since GX does allow for the definition and storage of 48 bit
  1126. per pixel data, could GX drive a special display board to help
  1127. drive us past the 8 bit grayscale ceiling. Maybe 16 bit grayscale
  1128. boards? :-)
  1129.  
  1130. This does have an application, really.
  1131.  
  1132. Many people in the medical imaging industry and some of our
  1133. customers (radiologists, etc.) believe that even though we have
  1134. been taught that the human eye can detect no more that 256 shades
  1135. of any given tone, that the ability to see 12 bits to 16 bits of
  1136. data is worthwhile and can make a difference on diagnosis. 
  1137.  
  1138.  
  1139. Willie Abrams                
  1140. Telemedicine Software Guy  Internet:  willie-abrams@uokhsc.edu
  1141. OU Health Sciences Center  AppleLink: Willie
  1142.  
  1143. +++++++++++++++++++++++++++
  1144.  
  1145. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1146. Date: 8 Jun 94 16:39:22 +1200
  1147. Organization: University of Waikato, Hamilton, New Zealand
  1148.  
  1149. In article <2svrum$dff@romulus.ucs.uoknor.edu>, Willie Abrams <willie-abrams@uokhsc.edu> writes:
  1150. >
  1151. > When the graphics system gets loaded, I assume GX walks the
  1152. > list of GDevices known to QuickDraw, and creates viewDevices
  1153. > for them...
  1154. >
  1155. > Would it be possible to have GX draw to a display that was not
  1156. > known to QuickDraw? That is, can GX recognize "GX" only display
  1157. > hardware?
  1158.  
  1159. GX can draw to offscreen ViewDevices, just like QuickDraw supports offscreen
  1160. GWorlds. They're easy to set up. You can even set up offscreen ViewGroups
  1161. (like the set of all screen devices is a ViewGroup), so you can draw a single
  1162. shape to multiple offscreen ViewDevices with a single GXDrawShape call.
  1163.  
  1164. > And since GX does allow for the definition and storage of 48 bit
  1165. > per pixel data, could GX drive a special display board to help
  1166. > drive us past the 8 bit grayscale ceiling. Maybe 16 bit grayscale
  1167. > boards? :-)
  1168.  
  1169. Unfortunately, last I checked in the (beta) documentation, GX cannot draw
  1170. _to_ a destination that has more than 8 bits per pixel component. I think it
  1171. can only read _from_ such a bitmap.
  1172.  
  1173. In short, you can certainly create and manipulate such a structure yourself,
  1174. no problem. And you can even get GX to display and print it (to within the
  1175. limits of your output hardware) once you've done. But GX will only be of
  1176. limited help with the manipulations.
  1177.  
  1178. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1179. Info & Tech Services Division              fax: +64-7-838-4066
  1180. University of Waikato            electric mail: ldo@waikato.ac.nz
  1181. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1182.  
  1183. +++++++++++++++++++++++++++
  1184.  
  1185. >From Cary Clark <crclark@apple.com>
  1186. Date: Wed, 8 Jun 1994 04:42:51 GMT
  1187. Organization: Apple Computer, Inc.
  1188.  
  1189. In article <2svrum$dff@romulus.ucs.uoknor.edu> Willie Abrams,
  1190. willie-abrams@uokhsc.edu writes:
  1191. >Would it be possible to have GX draw to a display that was not
  1192. >known to QuickDraw? That is, can GX recognize "GX" only display
  1193. >hardware?
  1194.  
  1195. Yes. An application can create a device in with the gxScreenViewDevices
  1196. viewGroup (1), and then it will be treated like all other physical
  1197. devices. If nil is passed for the mapping to GXSetViewDeviceMapping, the
  1198. device will be located adjacent to but not overlapping the other physical
  1199. devices.
  1200.  
  1201. >And since GX does allow for the definition and storage of 48 bit
  1202. >per pixel data, could GX drive a special display board to help
  1203. >drive us past the 8 bit grayscale ceiling. Maybe 16 bit grayscale
  1204. >boards? :-)
  1205.  
  1206. Sorry, but GX does not allow for pixel sizes greater than 32 bits. Nor
  1207. does it provide for 16 bits/pixel grayscale. But both of these are fine
  1208. enhancement requests for version 2.0.
  1209.  
  1210. Cary Clark
  1211. Apple Computer, Inc.
  1212.  
  1213. ---------------------------
  1214.  
  1215. >From kaltwasc@ucs.orst.edu (Chris Kaltwasser)
  1216. Subject: SEMI-SUMMARY: Reading JPEGs (with code)
  1217. Date: 8 Jun 1994 03:45:29 GMT
  1218. Organization: Oregon State University, Corvallis
  1219.  
  1220. Hello all,
  1221.     A while ago, I asked for a little help/advice on decompressing
  1222. JPEGs from JFIF files using QuickTime, and I'm very pleased to be able to
  1223. report success.  For the benefit of the Mac programming community, here is
  1224. the product of my efforts:
  1225.  
  1226.     This routine reads a JPEG file into an offscreen GWorld.  It would
  1227. not be too difficult to modify it to use an onscreen port instead.  It
  1228. assumes you've already checked for QuickTime and so forth.  Permission is
  1229. given to use this code for non-commercial purposes.  Use at your own risk.
  1230.  
  1231. - ------------------Cut Here--------------------
  1232.  
  1233. //______________________________________________________________________
  1234. //
  1235. //    Code for reading and writing JFIF files for SSConverter 1.4.1
  1236. //
  1237. //    Copyright (c)1994 by Chris Kaltwasser.  All rights reserved.
  1238. //
  1239. //______________________________________________________________________
  1240.  
  1241.  
  1242.  
  1243. #include <ImageCompression.h>
  1244. #include <FixMath.h>
  1245.  
  1246.  
  1247.  
  1248. #define JFIF_ID_MARKER        0xE0
  1249. #define JFIF_INFO_MARKER    0xC0
  1250.  
  1251.  
  1252.  
  1253. OSErr ReadJPEGFile(FSSpec *spec, GWorldPtr *gw)
  1254. {
  1255.     Rect srcRect;
  1256.     GDHandle gdh;
  1257.     PixMapHandle pix;
  1258.     ImageDescriptionHandle descH;
  1259.     CGrafPtr port;
  1260.     Byte *data = NULL, *s, id[5] = "JFIF";
  1261.     long length, i;
  1262.     short j, refnum, err, width, height;
  1263.  
  1264.     if (*gw)
  1265.         DisposeGWorld(*gw);
  1266.     *gw = NULL;
  1267.  
  1268.     err = FSpOpenDF(spec, fsRdPerm, &refnum);
  1269.     if (!err)
  1270.     {
  1271.         err = GetEOF(refnum, &length);
  1272.         if (!err && length < 170L) err = kReadFailErr;
  1273.         if (!err)
  1274.         {
  1275.             data = (Byte*)NewPtr(length);
  1276.             if (!data) err = memFullErr;
  1277.         }
  1278.         if (!err)
  1279.             err = FSRead(refnum, &length, data);
  1280.         FSClose(refnum);
  1281.     }
  1282.  
  1283.     if (!err)
  1284.     {
  1285.         /* make sure data is JFIF data stream */
  1286.         for (i = 0; i < length; ++i)
  1287.             if (data[i] == 0xFF && data[i+1] == JFIF_ID_MARKER)
  1288.             {
  1289.                 for (s = &data[i+4], j = 0; j < 5; ++s, ++j)
  1290.                     if (*s != id[j])
  1291.                     {
  1292.                         err = kBadJFIFErr;
  1293.                         j = 5;
  1294.                     }
  1295.                 i = length;
  1296.             }
  1297.         if (err) goto abortJPEG;
  1298.  
  1299.         /* read JPEG height and width from JFIF stream */
  1300.         err = kBadJFIFErr;
  1301.         for (i = 0; i < length; ++i)
  1302.             if (data[i] == 0xFF && data[i+1] == JFIF_INFO_MARKER)
  1303.             {
  1304.                 height = data[i+5]*256 + data[i+6];
  1305.                 width = data[i+7]*256 + data[i+8];
  1306.                 err = noErr;
  1307.                 i = length;
  1308.             }
  1309.  
  1310.         if (!err)
  1311.         {
  1312.             srcRect.top = 0;
  1313.             srcRect.left = 0;
  1314.             srcRect.bottom = height;
  1315.             srcRect.right = width;
  1316.  
  1317.             err = NewGWorld(gw, 24, &srcRect, NULL, NULL, 0);
  1318.  
  1319.             GetGWorld(&port, &gdh);
  1320.             SetGWorld(*gw, NULL);
  1321.             ClipRect(&srcRect);
  1322.             ForeColor(blackColor);
  1323.             BackColor(whiteColor);
  1324.  
  1325.             descH = (ImageDescriptionHandle)NewHandle(sizeof(ImageDescription));
  1326.             HLock((Handle)descH);
  1327.             (**descH).idSize = sizeof(ImageDescription);
  1328.             (**descH).cType = 'jpeg';    
  1329.             (**descH).resvd1 = 0L;
  1330.             (**descH).resvd2 = 0;
  1331.             (**descH).dataRefIndex = 0;
  1332.             (**descH).version = 1;
  1333.             (**descH).revisionLevel = 1;
  1334.             (**descH).vendor = 'appl';
  1335.             (**descH).temporalQuality = 0;
  1336.             (**descH).spatialQuality = 0;
  1337.             (**descH).width = width;
  1338.             (**descH).height = height;
  1339.             (**descH).vRes = (**descH).hRes = Long2Fix(72L);
  1340.             (**descH).dataSize = length;
  1341.             (**descH).frameCount = 1;
  1342.             BlockMove("\pPhoto - JPEG", (**descH).name, 32L);
  1343.             (**descH).depth = 24;
  1344.             (**descH).clutID = -1;
  1345.             HUnlock((Handle)descH);
  1346.  
  1347.             pix = GetGWorldPixMap(*gw);
  1348.  
  1349.             if (LockPixels(pix))
  1350.             {
  1351.                 err = DecompressImage((Ptr)data, descH, pix, &srcRect, &srcRect,
  1352.                                     srcCopy, NULL);
  1353.                 UnlockPixels(pix);
  1354.             }
  1355.             else
  1356.                 err = memFullErr;
  1357.  
  1358.             SetGWorld(port, gdh);                    /* restore port and device */
  1359.  
  1360.             DisposeHandle((Handle)descH);
  1361.         }
  1362.     }
  1363.  
  1364. abortJPEG:
  1365.     if (data) DisposePtr((Ptr)data);
  1366.  
  1367.     return err;
  1368. }
  1369.  
  1370. ---------------------------
  1371.  
  1372. >From euajgo@eua.ericsson.se (Joakim Grebeno)
  1373. Subject: VBL interrupt & Stack Sniffer
  1374. Date: 10 Jun 1994 07:53:37 GMT
  1375. Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  1376.  
  1377. I can't, over my dead body, find the information describing how to
  1378. enable/disable the stack sniffer! It is supposed to be done by toggling
  1379. a number of system globals but I can't find the info neither in IM 1-6
  1380. nor in the technotes!
  1381.  
  1382. I have the same problem to find which slot in the exception table the
  1383. VBL interrupt occupies!
  1384.  
  1385. Any experiences?
  1386.  
  1387. Thanks in advance!
  1388. Joakim
  1389.  
  1390. --
  1391. Joakim Grebenoe
  1392.  
  1393.  
  1394. +++++++++++++++++++++++++++
  1395.  
  1396. >From bwade@graphics.cornell.edu (Bretton Wade)
  1397. Date: 10 Jun 1994 12:24:44 GMT
  1398. Organization: Program of Computer Graphics -- Cornell University
  1399.  
  1400. I did this once, there is only one low mem global (try 0x0110?) and it used to
  1401. have the name StackLowPt, but I can't find it in the headers anymore. anyway,
  1402. just write a zero to that location to disable the sniffer. 
  1403.  
  1404. BTW, it seems that the thread manager extension from apple already disables
  1405. the sniffer on a global basis. can anybody substantiate this? Protected mem
  1406. would be a better scheme...
  1407. -- 
  1408. _______________________________________________________________________________
  1409.  
  1410.    Bretton Wade (bw16@cornell.edu)
  1411.  
  1412.    Program of Computer Graphics
  1413.    580 Engineering and Theory Center
  1414.    Cornell University
  1415.    Ithaca, NY 14853
  1416.    Voice: (607) 255-6704
  1417.    Fax:   (607) 255-0806
  1418. _______________________________________________________________________________
  1419.  
  1420. +++++++++++++++++++++++++++
  1421.  
  1422. >From ari@world.std.com (Ari I Halberstadt)
  1423. Date: Fri, 10 Jun 1994 15:51:26 GMT
  1424. Organization: The World Public Access UNIX, Brookline, MA
  1425.  
  1426. In article <2t9661$fds@euas20.eua.ericsson.se>,
  1427. Joakim Grebeno <euajgo@eua.ericsson.se> wrote:
  1428. >I can't, over my dead body, find the information describing how to
  1429. >enable/disable the stack sniffer! It is supposed to be done by toggling
  1430. >a number of system globals but I can't find the info neither in IM 1-6
  1431. >nor in the technotes!
  1432.  
  1433. Set the low-memory global StkLowPt to 0.
  1434. -- 
  1435. Ari Halberstadt                                 ari@world.std.com
  1436. One generation passes away, and another generation comes: but the
  1437. earth abides for ever. -- Ecclesiastes, 1:4.
  1438.  
  1439. +++++++++++++++++++++++++++
  1440.  
  1441. >From ari@world.std.com (Ari I Halberstadt)
  1442. Date: Fri, 10 Jun 1994 15:52:52 GMT
  1443. Organization: The World Public Access UNIX, Brookline, MA
  1444.  
  1445. In article <2t9m2c$e6a@merckx.graphics.cornell.edu>,
  1446. Bretton Wade <bw16@cornell.edu> wrote:
  1447. >BTW, it seems that the thread manager extension from apple already disables
  1448. >the sniffer on a global basis. can anybody substantiate this? Protected mem
  1449. >would be a better scheme...
  1450.  
  1451. The last version of the TM (pre-2.0) that I checked just set StkLowPt to zero.
  1452. -- 
  1453. Ari Halberstadt                                 ari@world.std.com
  1454. One generation passes away, and another generation comes: but the
  1455. earth abides for ever. -- Ecclesiastes, 1:4.
  1456.  
  1457. +++++++++++++++++++++++++++
  1458.  
  1459. >From brad@tazboy.jpl.nasa.gov (Brad Pickering)
  1460. Date: 10 Jun 1994 17:59:29 GMT
  1461. Organization: Jet Propulsion Laboratory, Pasadena, CA
  1462.  
  1463. In article <2t9661$fds@euas20.eua.ericsson.se> euajgo@eua.ericsson.se (Joakim Grebeno) writes:
  1464.  
  1465.    Path: elroy.jpl.nasa.gov!lll-winken.llnl.gov!sol.ctr.columbia.edu!howland.reston.ans.net!EU.net!sunic!sics.se!eua.ericsson.se!eua.ericsson.se!euajgo
  1466.    From: euajgo@eua.ericsson.se (Joakim Grebeno)
  1467.    Newsgroups: comp.sys.mac.programmer
  1468.    Date: 10 Jun 1994 07:53:37 GMT
  1469.    Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  1470.    Lines: 16
  1471.    NNTP-Posting-Host: euas66c13.eua.ericsson.se
  1472.    Keywords: VBL, Stack Sniffer
  1473.  
  1474.    I can't, over my dead body, find the information describing how to
  1475.    enable/disable the stack sniffer! It is supposed to be done by toggling
  1476.    a number of system globals but I can't find the info neither in IM 1-6
  1477.    nor in the technotes!
  1478.  
  1479. Set the low memory global called 'StkLowPt' to 0.
  1480. #include <SysEqu.h>
  1481.  
  1482. *(long *)StkLowPt = 0;
  1483.  
  1484.    I have the same problem to find which slot in the exception table the
  1485.    VBL interrupt occupies!
  1486.  
  1487. I think this depends on which mac you have. On the original macs it
  1488. is handled by the autoint1 vector (0x64), which calls some code that
  1489. dispatches through the second entry of the level 1 dispatch table (Lvl1DT + 0x04).
  1490. Some of this is documented in IM II pg 197.
  1491.  
  1492.  
  1493. Brad Pickering
  1494.  
  1495. +++++++++++++++++++++++++++
  1496.  
  1497. >From cverret@vub.ac.be (Verret Chris)
  1498. Date: 11 Jun 1994 06:56:00 GMT
  1499. Organization: Brussels Free Universities (VUB/ULB), Belgium
  1500.  
  1501. Joakim Grebeno (euajgo@eua.ericsson.se) wrote:
  1502. : I can't, over my dead body, find the information describing how to
  1503. : enable/disable the stack sniffer! It is supposed to be done by toggling
  1504. : a number of system globals but I can't find the info neither in IM 1-6
  1505. : nor in the technotes!
  1506.  
  1507. The following did the trick for me:
  1508.  
  1509.  
  1510.  
  1511. Ptr      stkLowPt : 0x110;
  1512. Ptr      savedStkLowPt;
  1513.  
  1514.  
  1515.  
  1516. savedStkLowPt = stkLowPt;
  1517. stkLowPt = NULL;
  1518.  
  1519.  
  1520.  
  1521. stkLowPt = savedStkLowPt;
  1522.  
  1523. +++++++++++++++++++++++++++
  1524.  
  1525. >From jumplong@aol.com (Jump Long)
  1526. Date: 12 Jun 1994 15:44:01 -0400
  1527. Organization: America Online, Inc. (1-800-827-6364)
  1528.  
  1529. In article <2t9661$fds@euas20.eua.ericsson.se>,
  1530. euajgo@eua.ericsson.se (Joakim Grebeno) writes:
  1531.  
  1532. >I can't, over my dead body, find the information describing how to
  1533. >enable/disable the stack sniffer!
  1534.  
  1535. I put a code snippet on the Developer CD called "Switch Stack" that
  1536. shows how to let interrupt code run on a private stack.  It also
  1537. disables and re-enables the stack sniffer correctly.
  1538.  
  1539. - Jim Luther
  1540.  
  1541.  
  1542. ---------------------------
  1543.  
  1544. >From Patrick.Stadelmann@etudiants.unine.ch
  1545. Subject: Writing dcmd with Think C (Q)
  1546. Date: 8 Jun 94 15:04:44 MET
  1547. Organization: University of Neuchatel
  1548.  
  1549.  Hi !
  1550.  
  1551.  Is it possible to write a dcmd with Think C ? If I include the .0 librairies
  1552.  in my project, I get link errors (like DATA_INIT undefined, or something
  1553.  like that).
  1554.  
  1555.  Is there a Think C port of these librairies available somewhere ?
  1556.  
  1557.  Thanks for your help
  1558.  
  1559.  Patrick
  1560.  
  1561. +++++++++++++++++++++++++++
  1562.  
  1563. >From egurney@vcd.hp.com (Eddy J. Gurney)
  1564. Date: Wed, 8 Jun 1994 17:30:28 GMT
  1565. Organization: Hewlett-Packard VCD
  1566.  
  1567. Patrick.Stadelmann@etudiants.unine.ch wrote:
  1568. > Is it possible to write a dcmd with Think C ? If I include the .0 librairies
  1569. > in my project, I get link errors (like DATA_INIT undefined, or something
  1570. > like that).
  1571.  
  1572. > Is there a Think C port of these librairies available somewhere ?
  1573.  
  1574. Even if you do get your 'dcmd' to build under Think, you'll STILL need
  1575. MPW to run the "BuildDCMD" Tool which Apple kindly supplies only as an
  1576. MPW tool, without any source.
  1577.  
  1578. I was about to try the same thing as you when I realized this "gotcha".
  1579.  
  1580. However, if someone has come up with a method for building dcmd's under
  1581. Think, I would love to hear about it.
  1582.  
  1583. --
  1584. Eddy J. Gurney N8FPW   Hewlett-Packard Company, Vancouver (USA!) Division
  1585. egurney@vcd.hp.com                       #include <standard-disclaimer.h>
  1586. "Failures are divided into two classes-- those who thought and never did,
  1587.       and those who did and never thought."     John Charles Salak
  1588.  
  1589. +++++++++++++++++++++++++++
  1590.  
  1591. >From eascharf@u.washington.edu (Elizabeth Scharf)
  1592. Date: 9 Jun 1994 04:21:53 GMT
  1593. Organization: University of Washington, Seattle
  1594.  
  1595. I managed to get TC 5 to build dcmds by using custom headers.  The main 
  1596. file looked like this:
  1597.  
  1598. void    CommandEntry    (void);
  1599. void    main            (void);
  1600.  
  1601. void main (void) 
  1602. {
  1603.     asm {
  1604.         @valid_A4:
  1605.             dc.w    2
  1606.             dc.w    0
  1607.             lea        @valid_A4,a0
  1608.             bra        CommandEntry
  1609.         } /* asm */
  1610.  
  1611. }
  1612.  
  1613. (remember, for a custom header, put NOTHING else in this file!)
  1614.  
  1615. The main dcmd entrypoint looked like this:
  1616.  
  1617. #include <SetUpA4.h>
  1618. #include "dcmd.h"
  1619.  
  1620. pascal void CommandEntry (
  1621.  
  1622.     dcmdBlock    *paramPtr)
  1623.  
  1624.     { /* begin CommandEntry */
  1625.  
  1626.         RememberA0();
  1627.         SetUpA4();
  1628.         
  1629.         switch (paramPtr->request) {
  1630. ...
  1631.  
  1632.             } /* switch */
  1633.         
  1634.         RestoreA4();
  1635.         
  1636.     } /* end CommandEntry */
  1637.  
  1638. (and you even get globals!)
  1639.  
  1640. I think I used oconv on the dcmdGlue.Lib, but it was a while ago...
  1641.  
  1642. Hope this helps.
  1643.  
  1644. rmgw
  1645.  
  1646. This is not my account:  Please address replies to hawkfish@aol.com
  1647.  
  1648. Disclaimer:  All views expressed are entirely my own and do not reflect 
  1649. the opinions of Elizabeth Scharf or the University of Washington.
  1650.  
  1651. - ---------------------------------------------------------------------------
  1652. Richard Wesley             | A Capitalist is someone who   | "Intel Inside"
  1653. hawkfish@aol.com           | knows the price of everything | is a warning 
  1654. 71062.1711@compuserve.com  | and the value of nothing.     | label...
  1655. - ---------------------------------------------------------------------------
  1656.  
  1657.  
  1658. ---------------------------
  1659.  
  1660. End of C.S.M.P. Digest
  1661. **********************
  1662.  
  1663.  
  1664.  
  1665.